#!/usr/bin/env python
"""world records grow with log(log(time))
see sdw aug 2008 p14ff
"""
import random, sys

mu = 100
sigma = 1
if len(sys.argv) == 2:
    mu = int(sys.argv[1])
    sigma = int(sys.argv[2])

max_repetitions		= 500
max_time		= 500

history = [0] * max_time

try:
#    while True:
    for n in range(1, max_repetitions+1):
	if n % 10 == 0:
	    print >> sys.stderr, n,
	record = 0
	for t in range(max_time):
	    sample = random.gauss(mu, sigma)
	    if sample > record:
		record = sample
	    # update history using a moving average
	    history[t] = history[t] + (record - history[t]) / float(n)
    
    for t in range(max_time):
	print t, history[t]
except KeyboardInterrupt:
    pass
